package top.stime21.framework.mvp

import android.support.annotation.CallSuper
import android.util.Log

/**
 * Author: czmc  Email: zxc6355533@163.com
 * Version:	1.0  Date:2018/3/1
 */

open abstract class MvpPresenter<V : MvpContract.View, M : MvpContract.Model> : MvpContract.Presenter {

    /** 视图  */
    var mView: V? = null
    /** 模型  */
    var mModel: M? = null

    constructor()
     constructor(view: V):this() {
        this.mView = view
    }

    constructor(view: V, model: M) {
        this.mView = view
        this.mModel = model
    }

    @CallSuper
    fun onViewDestroy() {
        mView = null
        mModel = null
        Log.d("framework","MvpPresenter - onViewDestroy")
    }

    override fun checkView(): Boolean {
        return view != null
    }

    override fun checkModel(): Boolean {
        return model != null
    }

    override fun check(): Boolean {
        return checkView() && checkModel()
    }

}